<?php

namespace app\index\model\tan;

use think\Model;

class Bankcard extends Model
{
    /**
     * 保存添加银行卡
     * @param array $data
     */
//    public function save($data){
//        echo "sdsd";
//    }
    
    public function save_($data){
        $this->state=0;
        $this->bankcard_id =$data['bankcard_id'];
        $this->user_id= \think\Session::get("user.id");
        $this->opening_bank =(int)$data['opening_bank'];
        $this->opening_bank_address =$data['opening_bank_address'];
        $this->createtime =date("Y-m-d H:i:s");
        $this->default =0;
        $this->phone=$data['phone'];
        $this->sort=$data['sort'];
        $this->name=$data['name'];
        return $this->save();
    }
    public function query_($id){
        $d= $this->where(["id"=>$id,"user_id"=> \think\Session::get("user.id") ] )->find();
        if(empty($d)){
            return null;
        }
        return $d->toArray();
    }
    public function up($id,$data){
//        return $this->where(["id"=>$id,"user_id"=> \think\Session::get("user.id")  ])->update([
//            "bankcard_id"=>(int)$data['opening_bank'],
//            "opening_bank_address"=>$data['opening_bank_address'],
//            "default"=>(int)$data['default'],
//            "sort"=>$data['sort'],
//            "phone"=>$data['phone'],
//        ]);
        return $this->where(["id"=>$id,"user_id"=> \think\Session::get("user.id")  ])->update($data);
    }
}
